Ext.define('ZYY.view.system.employeeEdit', {
    extend: 'Ext.window.Window',
    alias : 'widget.employeeEdit',
    requires: ['Ext.form.Panel'],
    layout: 'fit',
    autoShow: true,
    height: 340,
    width: 600,
    modal:true,
    initComponent: function() {
    	
    	selectImg=function(){
    		$("#file1").trigger("click");
    	}
    	uploadImg=function(obj){
    			$(obj).upload(path+"/admin/emp/photoupload.htm", function(data) {
		               $("#headimg").attr("src",path+data);
		               Ext.getCmp("headpic").setValue(data);
		            }, 'html');
    	}
    	var defaultImg="/resource/images/noavatar_big.gif";
    	var headImg=" <div style='width:235px;height:320px'>"
    				+"<img id='headimg' src='"+path+defaultImg+"'/>"
    				+"<input name='file' id='file1' type='file' style='display: none;' onchange='uploadImg(this)'>"
    				+"<input type='button' value='选择' onclick='selectImg()'>"
    				+"</div>";
    	
    	var comboxWithTree=Ext.create('Ext.form.field.Picker', {
    		name:"deptname",
		    fieldLabel : '所属部门',
			anchor : '99%',
			labelAlign : 'right',
			labelWidth: 70,
			allowBlank : false,
			editable : false,
		    createPicker: function() {
		        return Ext.create('Ext.tree.Panel', {
		        	pickerField: this,//注意这里用法
		            hidden: true,
		            floating: true,
		            minHeight: 300,
		            store:'system.deptTree',
		            rootVisible:false,
				    listeners:{
		                        select: function(thisTree, record, index, obj ){
		                           this.pickerField.setValue(record.data.text);
		                           this.pickerField.collapse();
		                           this.pickerField.up('window').down("hiddenfield[name=deptid]").setValue(record.data.id);
	                            },
	                            render:function(obj){
	                            	obj.expandAll();
	                            }
			           }
			        });
			     }
			});
	        this.items=[
	            {
                xtype: 'form',
                padding: '5 5 0 5',
                border: false,
                style: 'background-color: #fff;',
		        items:[{
		        	layout:"column",
		        	border:false,
		        	items:[{
			        			columnWidth : .5,
								defaultType : 'textfield',
								border : false,
						        defaults:{
							        	anchor : '99%',
										labelAlign : 'right',
										width:252,
										labelWidth: 70
									},
								items:[
										{ name : 'empno', allowBlank : false, vtype:"alphanum", fieldLabel: '登录帐号'},
										{ name : 'empname', allowBlank : false, vtype:"char", fieldLabel: '人员名称'},comboxWithTree,
		                   				{
								        	fieldLabel: '性别',
									        xtype: 'radiogroup',
							                columns: [100,100],
							                items: [{boxLabel: '男',inputValue: 1, checked: true, name: 'sex'},{boxLabel: '女', inputValue: 0, name: 'sex'}
							            ]},
								        { name : 'tel', fieldLabel: '联系方式',vtype:"mobile"  },
		                   				{ name : 'idcard', fieldLabel: '身份证号码' ,vtype:"IDCard" },
		                   				{ name : 'birthday', fieldLabel: '出生日期' ,xtype:"datefield",format: 'Y-m-d',editable:false},
		                   				{ name : 'address', fieldLabel: '联系地址' ,vtype:"char"},
		                   				{ name : 'status', fieldLabel: '状态' ,xtype: 'checkboxfield',boxLabel: '有效',checked:true,inputValue:true,uncheckedValue:false},
		                   				{ name : 'groupid', xtype: "hiddenfield" },
		                   				{ name : 'empid', xtype: "hiddenfield" },
		                   				{ name : 'emppass', xtype: "hiddenfield"},
		                   				{ name : 'headpic', id:"headpic",xtype: "hiddenfield",value:defaultImg},
		                   				{ name : 'deptid',xtype: "hiddenfield"}
									]
		        	        },
		        	        {
			        	        columnWidth : .1,
								border : false,
		        	        	html:"头像："
		        	        },
		        	        {
			        	        columnWidth : .4,
								border : false,
		        	        	html:headImg
		        	        }
		        	]
	         
		            }
		        ]
	        }],
        this.buttons = [
            {
                text: '保存',
                action: 'save'
            },
            {
                text: '取消',
                scope: this,
                handler: this.close
            }
        ];

        this.callParent(arguments);
    }
});

